import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myapp/app/theme/app_color.dart';

class CategoryTabLayout extends StatelessWidget {
  final List<String> tabs;

  final ValueChanged? onTab;

  CategoryTabLayout(this.tabs, {this.onTab});

  Widget _buildItem(String text, int index) {
    return Padding(
      padding: EdgeInsets.only(right: 10),
      child: Ink(
        decoration: BoxDecoration(
          color: AppColor.hex_ddd,
          borderRadius: BorderRadius.all(Radius.circular(20)),
        ),
        child: InkWell(
          borderRadius: BorderRadius.all(Radius.circular(20)),
          child: Container(
            padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
            child: Text(
              text,
              style: TextStyle(color: AppColor.hex_333, fontSize: 14),
            ),
          ),
          onTap: () => {onTab?.call(index)},
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: tabs.asMap().keys.map((e) => _buildItem(tabs[e], e)).toList(),
    );
  }
}
